package com.shujia.wyh.day12;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

/*
    字符输入流：Reader -- InputStreamReader
 */
public class ReaderDemo1 {
    public static void main(String[] args) throws IOException {
        //创建字符输入流对象
        //public InputStreamReader(InputStream in)
        InputStreamReader isr = new InputStreamReader(new FileInputStream("java/src/com/shujia/wyh/day12/d.txt"),"GBk");

        //public InputStreamReader(InputStream in,String charsetName)

        //读取数据的方式：
        //一次读取一个字符
//        int read = isr.read();
//        System.out.println((char) read);
//        int i = 0;
//        while ((i=isr.read())!=-1){
//            System.out.print((char) i);
//        }
//        System.out.println();

        //一次读取一个字符数组
//        char[] chars = new char[1024];
//        int length = 0;
//        while ((length=isr.read(chars))!=-1){
//            String s = new String(chars, 0, length);
//            System.out.println(s);
//        }



    }
}
